﻿<%@ Page Language="C#" MasterPageFile="~/web.master" AutoEventWireup="true" CodeBehind="branch_rollout_version_add.aspx.cs" Inherits="Shuba.Web.bulk_upload.branch_rollout_version_add" %>
<%@ Register Assembly="Shuba.Framework" Namespace="Shuba.Framework" TagPrefix="cc" %>
<asp:Content ID="Header1" ContentPlaceHolderID="HeaderPlaceHolder" runat="server">
<script type="text/javascript">

        function findCheckBox() {
        var valueCheckBox = document.all("ctl00_ContentPlaceHolder1_gvList").cells[0].children[2].checked;
        alert(valueCheckBox);
        
        var impDate = document.all("ctl00_ContentPlaceHolder1_gvList").cells;
         for (var n = 0; n < impDate.count; n++) {
                elm = document.forms[0].elements[n];
                if (elm.type == 'checkbox') {
                    elm.checked = checkVal;
                }
            }
        }
        
        function SetStatusImpDate()
        {
            var table = document.getElementById('<%= gvList.ClientID %>'); //document.all("ctl00_ContentPlaceHolder1_gvList");
            var impdate = document.getElementById('<%= txtImplDate.ClientID %>_foo'); //document.all("ctl00_ContentPlaceHolder1_txtImplDate_foo");
            document.getElementById('<%= hidIndex.ClientID %>').value = "true";//document.all("ctl00_ContentPlaceHolder1_hidIndex").value = "true";
            
            for (var i = 1; i < table.rows.length; i++)
            {
                var Row = table.rows[i].cells[3].innerText;
                var valueCheckBox = table.rows[i].cells[0].children[0].checked;
                
                if (Row != "" && valueCheckBox == true)
                {
                    if (Row != impdate.value)
                    {
                        document.getElementById('<%= hidIndex.ClientID %>').value = "false";
                        //document.all("ctl00_ContentPlaceHolder1_hidIndex").value = "false";
                        break;
                    }
                }
            }
        }
        
        function test3(sender, args) {
            alert(sender.checked);
        }
        
        function CheckImplementDate()
        {
            var isvalid = false;            
            for (var n = 0; n < document.forms[0].length; n++) {
                elm = document.forms[0].elements[n];
                if (elm.type == 'checkbox') {
                    if (elm.checked == true)
                        isvalid = true;
                }
            }
            
            if (!isvalid) {
                alert('Silakan dipilih cek box unit yang akan didaftarkan');
                isvalid = false;
            }
            
            if (isvalid)
            {
                if (document.getElementById('<%= hidIndex.ClientID %>').value == "false")
                {
                    isvalid = confirm('Implementation Date berbeda dengan yang telah ada\nApakah Anda yakin akan menimpa Implementaion Date yang telah ada dengan yang baru ?');
                }
            }
            return isvalid;
        }
        
        function Show(val) {
                alert(val);
                return false;
            }
            
        function CheckAll() {
            var checkVal;
            if (document.all("ButSelect").value == "Check All") {
                checkVal = true;
                document.all("ButSelect").value = "Un-Check All";
            } else {
                checkVal = false;
                document.all("ButSelect").value = "Check All";
            }

            for (var n = 0; n < document.forms[0].length; n++) {
                elm = document.forms[0].elements[n];
                if (elm.type == 'checkbox') {
                    elm.checked = checkVal;
                }
            }
        }
        
        function CheckValue() {
        var isvalid = false;
        for (var n = 0; n < document.forms[0].length; n++) {
            elm = document.forms[0].elements[n];
            if (elm.type == 'checkbox') {
                if (elm.checked == true)
                    isvalid = true;
            }
        }
        if (!isvalid) {
            alert('Silakan dipilih cek box unit yang akan didaftarkan');
            return false;
        }
        return isvalid;
    }
</script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="text" border="0" width="100%" cellspacing="0" cellpadding="2">
        <tr>
            <td class="text bg_content" bgcolor="#FFFFFF" align="center">
                <p>
                    &nbsp;</p>
                <table class="black" border="0" width="95%" cellspacing="0" cellpadding="0">
                    <tr>
                        <td class="title_back" align="left">
					    <table class="text" border="0" width="100%" cellspacing="0" cellpadding="0">
					    <tr>
					    <td class="title_back2" width="2%">&nbsp;</td>
					    <td class="title_back2 title_white" width="38%"><asp:Label ID="LabelTitle" runat="server" Text="Label"></asp:Label></td>
					    <td><span class="title_right"></span></td>
					    </tr>
					    </table>
                        </td>
                        <td class="title_back" align="right">&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="border_left bg_subtitle_white">&nbsp;&nbsp;&nbsp;</td>
                        <td class="border_right bg_subtitle" align="right">&nbsp;</td>
                    </tr>
                    <tr>
                        <td colspan="2">
                        
                        <table width=100% class="black border" border="0" cellspacing="0" cellpadding="2">
                       
					     <tr>
					        <td class="bg_grid" align="right">REGION</td>
					        <td class="bg_grid2" align="left">					        
					        <asp:DropDownList ID="ddlRegion" AutoPostBack="true" runat="server" Width="285px" CssClass="text" OnSelectedIndexChanged="ddlRegion_SelectedIndexChanged"></asp:DropDownList>&nbsp;
					        </td>
					     </tr>
					     <tr>
					        <td class="bg_grid" align="right">CLUSTER</td>
					        <td class="bg_grid2" align="left">
                            <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                            <ContentTemplate>
                            <asp:DropDownList ID="ddlCluster" AutoPostBack="true" runat="server" Width="285px" CssClass="text"></asp:DropDownList>&nbsp;
                            </ContentTemplate>
                            <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="ddlRegion" EventName="SelectedIndexChanged"/>
                            </Triggers>
                            </asp:UpdatePanel>
                            </td>
                          </tr>
					     <tr>
					        <td class="bg_grid" align="right">VERSION</td>
					        <td class="bg_grid2" align="left">
                            <asp:DropDownList ID="ddlVersion" runat="server" Width="285px" CssClass="text"></asp:DropDownList>
                            </td>
                          </tr>
                        <tr>
						    <td class="bg_grid" align="right" width="18%">IMPLEMENTATION DATE</td>
						    <td class="bg_grid2" align="left">
						    <cc:DatePicker ID="txtImplDate" imgDirectory="../images/" ControlCssClass="text" CssClass="text" runat="server"></cc:DatePicker>						    
						    </td>
						</tr>						
                        <tr>
                            <td class="bg_grid" align="right">&nbsp;</td>
                            <td class="bg_grid2" align="left">
                            <table border=0 cellpadding=0 cellspacing=0>
                            <tr>
                                <td>
                                    <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                                    <ContentTemplate>
						                <asp:Button ID="btnSearch" CssClass="buttonsmall" runat="server" Text="Search" OnClick="btnSearch_Click" />&nbsp;
						            </ContentTemplate>
						            <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="ddlCluster" EventName="SelectedIndexChanged"/>
                                    </Triggers>
						            </asp:UpdatePanel>
                                </td>
                            </tr>
                            </table>
                            </td>
                        </tr>                        
                        </table>
                        </td>
                        <tr>
                        <td class="border" colspan=2>
                        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                            <ContentTemplate>
                            <asp:HiddenField ID="hidIndex" runat="server" />
                            <cc:SHUBAGrid ID="gvList" runat="server" AutoGenerateColumns="False" Width="100%"
                                DataKeyNames="BranchID"
                                PageSize="20"
                                AllowSorting="True" onclick="SetStatusImpDate()" 
                                onselectedindexchanged="gvList_SelectedIndexChanged" 
                                onselectedindexchanging="gvList_SelectedIndexChanging" 
                                onrowcreated="gvList_RowCreated">
                                <Columns>
                                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Middle"
                                        HeaderStyle-Width="10%" ItemStyle-HorizontalAlign="Center">
                                        <HeaderTemplate>
                                            <input type="button" ID="ButSelect" name="ButSelect" value="Check All" class="button" onclick="CheckAll()">
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:CheckBox ID="chkItemSelect" runat="server" onclick="SetStatusImpDate()" /> <%--onclick="test3(this, null)"--%>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="BranchID" HeaderText="UNIT CODE" SortExpression="BranchID" ItemStyle-HorizontalAlign=Left />
                                    <asp:BoundField DataField="BranchName" HeaderText="UNIT NAME" SortExpression="BranchName" ItemStyle-HorizontalAlign=Left />
                                    <asp:BoundField HeaderText="IMPLEMENTATION DATE" ItemStyle-HorizontalAlign="Center" />                                    
                                </Columns>
                                <PagerSettings />
                                <EmptyDataTemplate>
                                    <table class="text" width=100% cellpadding=0 cellspacing=0><tr><td class="bg_grid2" align=center>NO RECORD FOUND</td></tr></table>
                                </EmptyDataTemplate>
                            </cc:SHUBAGrid>
                            <asp:Button ID="btnSubmit" runat="server" Text="Submit" Visible="false" CssClass="buttonsmall" onclick="btnSubmit_Click" OnClientClick="return CheckImplementDate()" />
                            <asp:Button ID="btnCancel" runat="server" Text="Cancel" Visible="false" CssClass="buttonsmall" CausesValidation="False" onclick="btnCancel_Click" />
						    &nbsp; &nbsp; 
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="gvList" EventName="PageIndexChanging"/>
                            <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click"/>
                        </Triggers>
                        </asp:UpdatePanel>
                        </td>
                     </tr>
                   </table>
                    <!-- Error Message -->
			        <table runat=server visible=false id="ErrBox" class="border" border="0" width="100%" cellspacing="0" cellpadding="2">
			        <tr>
			        <td class="bg_grid2" align=center><asp:Label ID="ErrMsg" runat="server" Text="" Font-Bold=true ForeColor="Red"></asp:Label></td>
			        </tr>
			        </table>
			        <!-- End Of Error Message -->
                </td>
            </tr>
        </table>
        
    <asp:UpdateProgress ID="UpdateProgress1" runat="server">
        <ProgressTemplate>
        <div class="progressBackgroundFilter"></div>
        <asp:Panel ID="pnlPopup" runat="server" CssClass="progress_popup">
        <div class="container_popup">
            <div class="header_popup">Generating Output, please wait...</div>
            <div class="body_popup">
                <img src="../images/activity.gif" />
            </div>
        </div>
        </asp:Panel>
        </ProgressTemplate>
    </asp:UpdateProgress>
</asp:Content>